<?php

	/**
	 * @see Bike_Initial
	 */
	require_once 'Bike/Initial.php';
	
	
	class Bike_IteratorArrayAccess extends Bike_Initial implements Iterator, ArrayAccess
	{
		protected $_position;
		protected $_data;

		public function __construct(array $Options = null)
		{
        	$this->_position = 0;
        	$this->_data = array();
        	if(!array_key_exists('data', $Options))
        	{        		$Options = array('data' => $Options);
        	}
        	parent::__construct($Options);
    	}

    	public function setData(array $Data)
    	{    		$this->_data = $Data;
    		return $this;
    	}

		public function offsetSet($offset, $value)
		{
		    if (is_null($offset))
		    {
		        $this->_data[] = $value;
		    } else {
		        $this->_data[$offset] = $value;
		    }
		}

		public function offsetExists($offset)
		{
		    return isset($this->_data[$offset]);
		}

		public function offsetUnset($offset)
		{
		    unset($this->_data[$offset]);
		}

		public function offsetGet($offset)
		{
		    return isset($this->_data[$offset]) ? $this->_data[$offset] : null;
		}

		public function rewind()
		{
		    $this->_position = 0;
		}

		public function current()
		{
		    return $this->_data[$this->_position];
		}

		public function key()
		{
		    return $this->_position;
		}

		public function next()
		{
		    ++$this->_position;
		}

		public function valid()
		{
		    return isset($this->_data[$this->_position]);
		}

		public function shift()
		{
		    $this->rewind();
		    return array_shift($this->_data);
		}

		public function join($Glue)
		{			return join($Glue, $this->_data);
		}
	}